package dk.mirasola.systemtraining.bridgewidgets.client.ui.distributionfiltereditor;

import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.uibinder.client.UiConstructor;
import com.google.gwt.user.client.ui.Image;

public class ToolbarImage extends Image {
    private ImageResource enabledIcon;
    private ImageResource disabledIcon;
    private boolean enabled = false;

    @UiConstructor
    public ToolbarImage(ImageResource enabledIcon, ImageResource disabledIcon) {
        super(disabledIcon);
        this.enabledIcon = enabledIcon;
        this.disabledIcon = disabledIcon;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
        if (enabled) {
            setUrl(enabledIcon.getURL());
        } else {
            setUrl(disabledIcon.getURL());
        }
    }

    public boolean isEnabled() {
        return enabled;
    }
}
